import java.io.*;
import java.net.Socket;

public class Client {

    public static void main(String[] args) {

        Socket socket = null;
        OutputStream outputStream = null;
        try {
            socket = new Socket("127.0.0.1", 10000);
            FileInputStream fileInputStream = new FileInputStream("F:\\IDEA\\算法练习\\src\\haha.xml");
            byte[] buffer = new byte[fileInputStream.available()];
            fileInputStream.read(buffer);
            outputStream = socket.getOutputStream();
            outputStream.write(buffer);
            outputStream.flush();

            fileInputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (socket != null) {
                try {
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            socket = null;
        }
    }
}
